package com.guojian.http.handle.route;

import org.smartboot.http.HttpRequest;
import org.smartboot.http.HttpResponse;
import org.smartboot.http.enums.HttpStatus;
import org.smartboot.http.server.handle.HttpHandle;
import org.smartboot.http.utils.HttpHeaderConstant;

public class Http404Handle extends HttpHandle {

	private static final String BODY_404 = "<html>" + "<head>" + "<title>404 not found</title>" + "</head>" + "<body><h1>404</h1><h2>未匹配到请求的路径,请检查RouteConfig</h2></body>" + "</html>";

	@Override
	public void doHandle(HttpRequest request, HttpResponse response) throws Exception {
		response.setHttpStatus(HttpStatus.NOT_FOUND);
		response.setHeader(HttpHeaderConstant.Names.CONTENT_TYPE, HttpHeaderConstant.Values.DEFAULT_CONTENT_TYPE);
		response.write(BODY_404.getBytes());
	}

}
